home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / game / shoot / ADoom_src_1_2.lha / ADoom_src / amiga_wad.s < prev    next >
Text File  |  1998-02-28  |  2KB  |  97 lines

  1.         mc68020
  2.  
  3.         xdef    @W_CacheLumpNum
  4.         xdef    _W_CacheLumpNum
  5.  
  6.         section    text,code
  7.  
  8.         near    a4,-2
  9.  
  10. ;-----------------------------------------------------------------------
  11. ; R_CacheLumpNum (in w_wad.c) by Arto Huusko <arto.huusko@pp.qnet.fi>
  12.  
  13.         xref    _numlumps    ;int
  14.         xref    _lumpcache    ;void**
  15.  
  16.         xref    @W_LumpLength
  17.         xref    @W_ReadLump
  18.         xref    @Z_ChangeTag2
  19.         xref    _I_Error
  20.         xref    @Z_Malloc
  21.  
  22.         cnop    0,4
  23. _W_CacheLumpNum:
  24. @W_CacheLumpNum:
  25.         cmp.l    _numlumps(a4),d0
  26.         bpl.b    .wc_Error
  27.  
  28.         move.l    a2,-(sp)
  29.  
  30.         move.l    _lumpcache(a4),a2
  31.         lea    (a2,d0.l*4),a2
  32.         tst.l    (a2)
  33.         beq.b    .wc_Miss
  34.         move.l    (a2),a0
  35.         move.l    d1,d0
  36.         jsr    (@Z_ChangeTag2)
  37.         move.l    (a2),d0
  38.  
  39.         move.l    (sp)+,a2
  40.         rts
  41.  
  42.         cnop    0,4
  43. .wc_Miss:
  44.         movem.l    d2/d3,-(sp)
  45.         move.l    d0,d2
  46.         move.l    d1,d3
  47.         jsr    (@W_LumpLength)
  48.         move.l    d3,d1
  49.         move.l    a2,a0
  50.         jsr    (@Z_Malloc)
  51.         move.l    d2,d0
  52.         move.l    (a2),a0
  53.         jsr    (@W_ReadLump)
  54.         move.l    (a2),d0
  55.         movem.l    (sp)+,d2/d3/a2
  56.         rts
  57. .wc_Error:
  58.         move.l    #.wc_Msg,-(sp)
  59.         move.l    d0,-(sp)
  60.         jsr    (_I_Error)
  61.         addq.l    #8,sp
  62.         rts
  63.  
  64. .wc_Msg:
  65.         dc.b    "W_CacheLumpNum: %i >= numlumps",0
  66.  
  67. ;void*
  68. ;W_CacheLumpNum
  69. ;( int        lump,
  70. ;  int        tag )
  71. ;{
  72. ;    byte*    ptr;
  73. ;
  74. ;    if ((unsigned)lump >= numlumps)
  75. ;    I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
  76. ;        
  77. ;    if (!lumpcache[lump])
  78. ;    {
  79. ;    // read the lump in
  80. ;    
  81. ;    //printf ("cache miss on lump %i\n",lump);
  82. ;    ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]);
  83. ;    W_ReadLump (lump, lumpcache[lump]);
  84. ;    }
  85. ;    else
  86. ;    {
  87. ;    //printf ("cache hit on lump %i\n",lump);
  88. ;    Z_ChangeTag (lumpcache[lump],tag);
  89. ;    }
  90. ;    
  91. ;    return lumpcache[lump];
  92. ;}
  93.  
  94. ;-----------------------------------------------------------------------
  95.  
  96.         end
  97.